function CreateCtrl($scope, $http, $location, $log){
	$scope.reset = function(){
		$log.log('reset form...');
		$scope.dish.name = "";
		$scope.dish.description = "";
		$scope.dish.style = "";
	}

	$scope.save = function(){
		$log.log('submit form to server...' + $scope.dish.name);

		$http({
			method: 'POST',
			url: '/api/menu',
			data: $scope.dish
		}).success(function(data, status, headers, config){
			$location.path('/');
		}).error(function(data, status, headers, config){
			$log.log('Create failed');
		});
	}
}

function UpdateCtrl($scope, $http, $location, $log, $routeParams){
	var id = $routeParams.id;
	$http.get('/api/menu/' + id).success(function(dish){
		$scope.originDish = dish;
		$scope.dish = $scope.originDish;

		$log.log('orgin: ' + $scope.originDish._id);
	});

	$scope.reset = function(){
		$log.log('reset form...');

		$scope.dish.name = $scope.originDish.name;
		$scope.dish.description = $scope.originDish.description;
		$scope.dish.style = $scope.originDish.style;
	}

	$scope.save = function(){
		$log.log('submit form to server...' + $scope.dish.name + ' _id: ' + $scope.dish._id);

		$http({
			method: 'PUT',
			url: '/api/menu/'+id,
			data: $scope.dish
		}).success(function(data, status, headers, config){
			$location.url('/');
		}).error(function(data, status, headers, config){
			$log.log('Update failed');
		});
	}
}